package com.ruoyi.common.scheduledtasks;

import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.uuid.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * 是管理员做身份验证的
 * */
@Configuration // 标记配置类
@EnableScheduling // 开启定时任务
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
public class ScheduleTasksGenderTodayId {
    /**
     * redis服务
     */
    @Resource
    private RedisCache redisCache;

    // 生成一个只有管理员才知道的id, 这个id存放在redis和日志中
    @Scheduled(cron = "0 0 * * * *")
    @PostConstruct
    public void genderUUID() {
        String token = UUID.randomUUID().toString();
        redisCache.setCacheObject("admin__UUID", token);
        log.info(token);
    }
}
